package com.nolon.flange.tools

import org.apache.poi.hssf.usermodel.HSSFCellStyle
import org.apache.poi.hssf.usermodel.HSSFFont
import org.apache.poi.hssf.util.HSSFColor
import org.apache.poi.ss.usermodel.CellStyle
import org.apache.poi.ss.usermodel.Workbook

val Workbook.titleRow: CellStyle
    get() {
        val fontBase = this.createFont().apply {
            fontName = HSSFFont.FONT_ARIAL
            fontHeightInPoints = 16.toShort()
            boldweight = HSSFFont.BOLDWEIGHT_BOLD

        }
        return this.createCellStyle().apply {
            alignment = HSSFCellStyle.ALIGN_CENTER_SELECTION
            fillBackgroundColor = HSSFColor.LIME.index
            fillPattern = HSSFCellStyle.SOLID_FOREGROUND
            setFont(fontBase)
            borderTop = HSSFCellStyle.BORDER_MEDIUM
            borderBottom = HSSFCellStyle.BORDER_MEDIUM
            borderLeft = HSSFCellStyle.BORDER_MEDIUM
            borderRight = HSSFCellStyle.BORDER_MEDIUM
        }
    }


val Workbook.headerRow: CellStyle
    get() {
        val fontBase = this.createFont().apply {
            fontName = HSSFFont.FONT_ARIAL
            boldweight = HSSFFont.BOLDWEIGHT_BOLD
            fontHeightInPoints = 12.toShort()
        }
        return this.createCellStyle().apply {
            alignment = HSSFCellStyle.ALIGN_CENTER
            verticalAlignment = HSSFCellStyle.VERTICAL_CENTER
            fillPattern = HSSFCellStyle.SOLID_FOREGROUND
            setFont(fontBase)
            wrapText = true
            borderTop = HSSFCellStyle.BORDER_MEDIUM
            borderBottom = HSSFCellStyle.BORDER_MEDIUM
            borderLeft = HSSFCellStyle.BORDER_MEDIUM
            borderRight = HSSFCellStyle.BORDER_MEDIUM
        }
    }

val Workbook.contentRow: CellStyle
    get() {
        val fontBase = this.createFont().apply {
            fontName = HSSFFont.FONT_ARIAL
            fontHeightInPoints = 12.toShort()
        }
        return this.createCellStyle().apply {
            alignment = HSSFCellStyle.ALIGN_CENTER
            verticalAlignment = HSSFCellStyle.VERTICAL_CENTER
            fillPattern = HSSFCellStyle.SOLID_FOREGROUND
            setFont(fontBase)
            borderTop = HSSFCellStyle.BORDER_MEDIUM
            borderBottom = HSSFCellStyle.BORDER_MEDIUM
            borderLeft = HSSFCellStyle.BORDER_MEDIUM
            borderRight = HSSFCellStyle.BORDER_MEDIUM
        }
    }


val Workbook.mergeTitleStyle: CellStyle
    get() {
        val fontBase = this.createFont().apply {
            fontName = HSSFFont.FONT_ARIAL
            fontHeightInPoints = 20.toShort()
        }
        return this.createCellStyle().apply {
            alignment = HSSFCellStyle.ALIGN_CENTER
            verticalAlignment = HSSFCellStyle.VERTICAL_CENTER
            fillPattern = HSSFCellStyle.SOLID_FOREGROUND
            setFont(fontBase)
            borderTop = HSSFCellStyle.BORDER_MEDIUM
            borderBottom = HSSFCellStyle.BORDER_MEDIUM
            borderLeft = HSSFCellStyle.BORDER_MEDIUM
            borderRight = HSSFCellStyle.BORDER_MEDIUM
        }
    }

